//
//  CYStatusCellBottomView.swift
//  CYSinaWB
//
//  Created by mac on 16/2/24.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit
import SnapKit

class CYStatusCellBottomView: UIView {
    //MARK: 用户点击事件
    //每一个继承自 UIReponder的对象 都会添加到 响应者链条中
    //就需要遍历响应者链条 获取 导航视图控制器  进行页面跳转
    @objc private func repostBtnDidClick() {
        let temp = CYTempViewController()
        temp.hidesBottomBarWhenPushed = true
        navViewController()?.pushViewController(temp, animated: true)
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor(white: 0.8, alpha: 1)
        setUpUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    private func setUpUI() {
        addSubview(repostBtn)
        addSubview(commentBtn)
        addSubview(zanBtn)
        
        repostBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self.snp_left)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
        }
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(repostBtn.snp_right)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            make.width.equalTo(repostBtn.snp_width)
        }
        zanBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            make.width.equalTo(commentBtn.snp_width)
            make.right.equalTo(self.snp_right)
        }
        let sView1 = setView()
        let sView2 = setView()
        addSubview(sView1)
        addSubview(sView2)
        sView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(repostBtn.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            //黄金分割比 1:0.618
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
            make.width.equalTo(0.5)
        }
        // view1.attr1 = view2.attr2 * multiplier + constant
        sView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
            make.width.equalTo(0.5)
        }
        repostBtn.addTarget(self, action: "repostBtnDidClick", forControlEvents: .TouchUpInside)
    }
    
    private func setView() -> UIView {
        let s = UIView()
        s.backgroundColor = UIColor.darkGrayColor()
        return s
    }
    
    //转发btn
    private lazy var repostBtn: UIButton = UIButton(backName: nil, title: "转发", textColor: UIColor.lightGrayColor(), imageName: "timeline_icon_retweet")
    //评论btn
    private lazy var commentBtn: UIButton = UIButton(backName: nil, title: "评论", textColor: UIColor.lightGrayColor(), imageName: "timeline_icon_comment")
    //赞btn
    private lazy var zanBtn: UIButton = UIButton(backName: nil, title: "赞", textColor: UIColor.lightGrayColor(), imageName: "timeline_icon_unlike")
}
